select ' INSERT INTO payrolldates(PAYROLLDATEKEY,DATESTART,DATEEND,DTR,PAYROLLSUMMARY,COMMENTS) VALUES (' 
+ ISNULL(str(PAYROLLDATEKEY,4),'Null')
+ ',''' + isnull(convert(varchar(10),DATESTART,126),'1899-12-01')
+ ''',''' + isnull(convert(varchar(10),DATEEND,126),'1899-12-01')
+ ''',''' + ISNULL(DTR,'')
+ ''',''' + ISNULL(PAYROLLSUMMARY,'')
+ ''',''' + ISNULL(COMMENTS,'')+ ''')' from payrolldates order by PAYROLLDATEKEY
